<?php /* Smarty version 2.6.27, created on 2019-11-04 17:31:57
         compiled from common/multiSelectServer.tpl */ ?>
<input type="checkbox" id="all" value="">全选
<?php $_from = $this->_tpl_vars['list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['item']):
?>
    <input type="checkbox" class="serverids" name= "serverid[]" value="<?php echo $this->_tpl_vars['item']['server_id']; ?>
" <?php if (in_array ( $this->_tpl_vars['item']['server_id'] , $this->_tpl_vars['selected'] )): ?>checked <?php endif; ?>/><?php echo $this->_tpl_vars['item']['server_id']; ?>
-<?php echo $this->_tpl_vars['item']['name']; ?>
(<?php echo $this->_tpl_vars['item']['channel']; ?>
)&nbsp;&nbsp;
<?php endforeach; endif; unset($_from); ?>

<script type="text/javascript">
    function getServerId() {
        var serverid = '';
        $("input[type=checkbox]").each(function(){
            if( $(this).prop("checked") && $(this).val() ){
                if($(this).val() != ''){
                    serverid += $(this).val() + ",";
                }
            }
        })
        return serverid.substr(0,serverid.length-1);
    }

    $("#all").click(function(){
         if($(this).prop("checked")){
             //$(":checkbox").attr("checked","checked");
             $(".serverids").attr("checked","checked");
         }else{
             $(":checkbox").removeAttr("checked");
         }
    })
</script>